﻿using MediatR;
using RBAC.Domain;
using RBAC.Server.Interface;
using Swork03_28.Api.Application.Commands.RoleCommand;

namespace Swork03_28.Api.Application.CommandHandlers.RoleHandler
{
    public class RoleSelectCommandHandler : IRequestHandler<RoleSelectCommand, (int totalCount, int pageCount, List<Roles> list)>
    {
        private readonly IRoleServer roleServer;

        public RoleSelectCommandHandler(IRoleServer roleServer)
        {
            this.roleServer = roleServer;
        }

        public async Task<(int totalCount, int pageCount, List<Roles> list)> Handle(RoleSelectCommand request, CancellationToken cancellationToken)
        {
            return await roleServer.GetRoles(request.pageIndex, request.pageSize);
        }
    }
}
